home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / var / lib / python-support / python2.6 / gdata / codesearch / service.pyc (.txt) < prev   
Encoding:
Python Compiled Bytecode  |  2009-04-20  |  4.7 KB  |  89 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. '''CodesearchService extends GDataService to streamline Google Codesearch 
  5. operations'''
  6. __author__ = 'Benoit Chesneau'
  7. import atom
  8. import gdata.service as gdata
  9. import gdata.codesearch as gdata
  10.  
  11. class CodesearchService(gdata.service.GDataService):
  12.     '''Client extension for Google codesearch service'''
  13.     
  14.     def __init__(self, email = None, password = None, source = None, server = 'www.google.com', additional_headers = None, **kwargs):
  15.         """Creates a client for the Google codesearch service.
  16.  
  17.         Args:
  18.           email: string (optional) The user's email address, used for
  19.               authentication.
  20.           password: string (optional) The user's password.
  21.           source: string (optional) The name of the user's application.
  22.           server: string (optional) The name of the server to which a connection
  23.               will be opened. Default value: 'www.google.com'.
  24.           **kwargs: The other parameters to pass to gdata.service.GDataService
  25.               constructor.
  26.         """
  27.         gdata.service.GDataService.__init__(self, email = email, password = password, service = 'codesearch', source = source, server = server, additional_headers = additional_headers, **kwargs)
  28.  
  29.     
  30.     def Query(self, uri, converter = gdata.codesearch.CodesearchFeedFromString):
  31.         '''Queries the Codesearch feed and returns the resulting feed of
  32.            entries.
  33.  
  34.         Args:
  35.         uri: string The full URI to be queried. This can contain query
  36.              parameters, a hostname, or simply the relative path to a Document
  37.              List feed. The DocumentQuery object is useful when constructing
  38.              query parameters.
  39.         converter: func (optional) A function which will be executed on the
  40.                    retrieved item, generally to render it into a Python object.
  41.                    By default the CodesearchFeedFromString function is used to
  42.                    return a CodesearchFeed object. This is because most feed
  43.                    queries will result in a feed and not a single entry.
  44.  
  45.         Returns :
  46.             A CodesearchFeed objects representing the feed returned by the server
  47.         '''
  48.         return self.Get(uri, converter = converter)
  49.  
  50.     
  51.     def GetSnippetsFeed(self, text_query = None):
  52.         '''Retrieve Codesearch feed for a keyword
  53.  
  54.         Args:
  55.             text_query : string (optional) The contents of the q query parameter. This
  56.                          string is URL escaped upon conversion to a URI.
  57.         Returns:
  58.             A CodesearchFeed objects representing the feed returned by the server
  59.         '''
  60.         query = gdata.codesearch.service.CodesearchQuery(text_query = text_query)
  61.         feed = self.Query(query.ToUri())
  62.         return feed
  63.  
  64.  
  65.  
  66. class CodesearchQuery(gdata.service.Query):
  67.     '''Object used to construct the query to the Google Codesearch feed. here only as a shorcut'''
  68.     
  69.     def __init__(self, feed = '/codesearch/feeds/search', text_query = None, params = None, categories = None):
  70.         """Constructor for Codesearch Query.
  71.  
  72.         Args:
  73.             feed: string (optional) The path for the feed. (e.g. '/codesearch/feeds/search')
  74.             text_query: string (optional) The contents of the q query parameter. This
  75.                         string is URL escaped upon conversion to a URI.
  76.             params: dict (optional) Parameter value string pairs which become URL
  77.                     params when translated to a URI. These parameters are added to
  78.                     the query's items.
  79.             categories: list (optional) List of category strings which should be
  80.                         included as query categories. See gdata.service.Query for
  81.                         additional documentation.
  82.  
  83.         Yelds:
  84.             A CodesearchQuery object to construct a URI based on Codesearch feed
  85.         """
  86.         gdata.service.Query.__init__(self, feed, text_query, params, categories)
  87.  
  88.  
  89.